<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="pc/include :: header('专题')" />

    <link th:href="@{/js/ui-table/ui-table.css}" rel="stylesheet"/>
</head>
<body>
<th:block th:include="pc/include :: top" />
<div class="iw">
    <div class="crumbs">
        <p>当前位置：<a href="/">首页</a> > <a href="#">专题</a> > 评论评论</p>
    </div>
    <div class="comment-edit">
        <label><a href='#' th:text="${topic_title}"></a></label>
        <label>评论 : <span th:utext="${comment.comment}" th:remove="tag"></span> </label>
        <script id="editor" name='word' type="text/plain"></script>
        <div class="btn">提交</div>
    </div>
</div>
<th:block th:include="pc/include :: footer" />
<script type="text/javascript">
    var ctxPath= "[[${#httpServletRequest.getContextPath()}]]";
    window.CTX = ctxPath;
</script>
<link type="text/css" th:href="@{/js/ui-editor/ui-editor.css}" rel="stylesheet" />
<script type="text/javascript" charset="utf-8" th:src="@{/js/neditor/neditor.config.js}"></script>
<script type="text/javascript" charset="utf-8" th:src="@{/js/neditor/neditor.all.js}"></script>
<script>
    $(function() {

        var ue = UE.getEditor('editor', {
            initialFrameHeight: 200,
            initialFrameWidth: '100%',
            serverUrl: window.CTX + "/ueditor/config",
            elementPathEnabled: false,
            toolbars: [
                [
                    "bold",
                    "italic",
                    "underline",
                    "forecolor",
                    "backcolor",
                    "fontfamily",
                    "fontsize",
                    "justifyleft",
                    "justifycenter",
                    "justifyright",
                    "link",
                    "unlink",
                    "simpleupload",
                    "emotion",
                ]
            ]
        });

        $(".comment-edit .btn").click(function(e) {
            e.preventDefault();

            var comment = ue.getContent();
            if (comment == '') {
                Message('请输入评论内容');
                return false;
            }

            var $this = $(this);
            if ($this.hasClass("doing"))
                return;
            $this.addClass("doing");
            $.post('/topic/replycommentadd', {
                commentid:[(${comment.commentid})],
                topicid:[(${comment.topicid})],
                comment: comment
            }, function(data) {
                if (data == "-1") {
                    ShowTip('评论失败');
                } else {
                    ShowTip('评论已提交');
                }
                $this.removeClass("doing");
                location = "/topic/[(${comment.topicid})]";
            });
        });

    });
</script>